{extend name="layout/goods" /}
{block name="content"}
<!--主体-->
<header class="wy-header">
    <a href="javascript:history.back(-1);"><div class="wy-header-icon-back"><span></span></div></a>
    <div class="wy-header-title">{$title}</div>
</header>
<div class="weui-content">
    <form id="address-form" action="" method="post">
        <div class="weui-cells weui-cells_form wy-address-edit">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label wy-lab">收货人</label></div>
                <div class="weui-cell__bd"><input class="weui-input" name="consignee" type="text" placeholder="" value="{$address.consignee}"></div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label wy-lab">手机号</label></div>
                <div class="weui-cell__bd"><input class="weui-input" name="mobile" value="{$address.mobile}" type="number" length="11" pattern="[0-9]*" placeholder=""></div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="name" class="weui-label wy-lab">所在地区</label></div>
                <div class="weui-cell__bd"><input class="weui-input" name="area" id="address" type="text" value="{$address.area}" readonly=""></div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label wy-lab">详细地址</label></div>
                <div class="weui-cell__bd">
                    <textarea class="weui-textarea" name="address" placeholder="">{$address.address}</textarea>
                </div>
            </div>
            <div class="weui-cell weui-cell_switch">
                <div class="weui-cell__bd">设为默认地址</div>
                <div class="weui-cell__ft"><input class="weui-switch" name="is_default" type="checkbox" {if condition="$address.is_default eq 1"}checked{/if}></div>
            </div>
        </div>
        <div class="weui-btn-area">
            <button class="weui-btn weui-btn_primary" type="button" id="showTooltips">保存此地址</button>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script src="__CDN__/assets/js/city-picker.js"></script>
<script>
$("#address").cityPicker({
    title: "选择地址",
});
$('#showTooltips').click(function() {
    $.ajax({
      	url: $('#address-form').attr('action'),
      	type: 'POST',
      	data: $('#address-form').serialize(),
        success: function(data) {
            if(!data.code) {
                alert(data.msg);
            }else{
                window.location.href = data.url;
            }
        },
    })
})
</script>
{/block}
